package com.prs.crm.action.oa;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.domain.oa.CustomButtonSet;
import com.prs.crm.domain.oa.FramesSet;
import com.prs.crm.service.oa.CustomButtonSetService;
import com.prs.crm.service.oa.FramesSetService;

/**
 * @author YangHao
 * @E-Mail:450098606@qq.com
 * @qq:450098606
 * @version 创建时间：2012-5-11 9:32:14 自定义画面
 */
public class FramesSetAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private FramesSet framesSet;
	private FramesSetService framesSetService;
	private PaginationSupport pagination;
	private List<CustomButtonSet> custom;
	private CustomButtonSetService customButtonSetService;
	private String type;
	private Integer[] ids;
	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	public FramesSet getFramesSet() {
		return framesSet;
	}
	public void setFramesSet(FramesSet framesSet) {
		this.framesSet = framesSet;
	}
	public FramesSetService getFramesSetService() {
		return framesSetService;
	}
	public void setFramesSetService(FramesSetService framesSetService) {
		this.framesSetService = framesSetService;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	public List<CustomButtonSet> getCustom() {
		return custom;
	}
	public void setCustom(List<CustomButtonSet> custom) {
		this.custom = custom;
	}
	public CustomButtonSetService getCustomButtonSetService() {
		return customButtonSetService;
	}
	public void setCustomButtonSetService(
			CustomButtonSetService customButtonSetService) {
		this.customButtonSetService = customButtonSetService;
	}	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	@Action("listFramesSet")
	public String listFramesSet(){
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(FramesSet.class);
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getFramesSetService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	@Action("editFramesSet")
	public String editFramesSet(){
//		this.customButtonSet=this.customButtonSetService.getAllCustomButtomSet();
		return SUCCESS;
	}
	
	@Action(value="saveFramesSet",results={
			@Result(name="success",type="redirect",location="listFramesSet"),
			@Result(name="error",type="chain",location="editFramesSet")
	})
	public String saveFramesSet(){
		framesSet.setType("浏览画面");
		this.getFramesSetService().save(framesSet);
		return SUCCESS;
	}
	
	@Action(value="removeFramesSet",results={
			@Result(name="success",type="redirect",location="listFramesSet"),
			@Result(name="error",type="chain",location="editFramesSet")
	})
	public String removeFramesSet(){
		this.getFramesSetService().batchRemove(ids);
		return SUCCESS;
	}
}
